import { ElMessage } from 'element-plus';
import { loginApi } from '@/api/login';

export const useLogin = (router) => async (formRef, data) => {
  await formRef.value.validate();
  // 调接口，登录
  const res = await loginApi(data);
  // 存储到本地
  localStorage.token = res.data;
  // 跳转页面
  router.push({ name: 'UsersIndex' });
  ElMessage.success('登陆成功');
};

export default {};
